<?php

    // +----------------------------------------------------------------------
    // | 行为日志模型
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------

    namespace app\model\ucenter;

    use think\facade\Db;

    class UserCode extends Common
    {


        // 定义关联方法
        public function user()
        {
            return $this->belongsTo(User::class);
        }
  

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
			$data['ip'] = request()->ip();
//			$data['os'] = request()->server('HTTP_USER_AGENT');
			$data['param'] = '';
		}



        public function getCreateTimeAttr($value,$data)
        {
            return $value ? $value : date('Y-m-d H:i:s',$data['createtime']);
        }

        public function getPosterImageAttr($value,$data)//poster_image
        {
            return strpos($value,'http') !== false ? $value : (request()->domain().$value);
        }
        public function getCodeImageAttr($value,$data)//poster_image
        {
            return strpos($value,'http') !== false ? $value : (request()->domain().$value);
        }

    }
